using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace Wallpaper
{
    class CommonTask<TParams, TProgress, TResult> : AsyncTask<TParams, TProgress, TResult>
    {
        public Func<TParams[], TResult> Runner { get; set; }
        public Action<TResult> Poster { get; set; }

        protected override TResult RunInBackground(params TParams[] @params)
        {
            if (Runner != null)
            {
                return Runner(@params);
            }
            return default(TResult);
        }

        protected override void OnPostExecute(TResult result)
        {
            if (Poster != null)
            {
                Poster(result);
            }
        }
    }
}